package com.dgut.coal.controller;

import com.dgut.coal.service.AuditService;
import com.dgut.coal.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * @Author: Yang
 * @Description:
 * @Date: Created in 19:04 2019/10/5
 * @Modifued BY:
 */

@Controller
public class AuditController {


    @Autowired
    AuditService auditService;

    @Autowired
    PurchaseService ps;

    @RequestMapping("/passPur")
    @ResponseBody
    public int passPur(Integer apply_id,String operator, String audit_content){
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String audit_date = format.format(new Date());
        int row = auditService.pass(apply_id,operator,audit_content,audit_date);
        ps.auditStatePass(apply_id);
        return row;
    }

    @RequestMapping("/rejectPur")
    @ResponseBody
    public int rejectPur(Integer apply_id,String operator, String audit_content){
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String audit_date = format.format(new Date());
        int row = auditService.reject(apply_id,operator,audit_content,audit_date);
        ps.auditStateReject(apply_id);
        return row;
    }

}
